package qldc.pm.tiensu.searchcontainer;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.portlet.PortletRequest;
import javax.portlet.PortletURL;

import qldc.pm.csdl.cd90.model.QuanHeVoiChuHo;
import qldc.pm.tiensu.constants.TienSuConstants;
import qldc.pm.tiensu.dto.DanhSachTienSuDTO;

import com.liferay.portal.kernel.dao.search.SearchContainer;

public class DSHoGiaDinhSearch extends SearchContainer<QuanHeVoiChuHo>  {
	public static final String EMPTY_RESULTS_MESSAGE = "khong-tim-thay-ho-gia-dinh-co-tien-su-nao";
	static List<String> headerNames = new ArrayList<String>();
	public DSHoGiaDinhSearch(PortletRequest portletRequest, PortletURL iteratorURL) {
		
		super(portletRequest, new DSHoGiaDinhDisplayTerms(portletRequest),
				new DSHoGiaDinhSearchTerms(portletRequest),
				DEFAULT_CUR_PARAM, DEFAULT_DELTA, iteratorURL, headerNames,
				EMPTY_RESULTS_MESSAGE);
		DSHoGiaDinhDisplayTerms displayTerms = (DSHoGiaDinhDisplayTerms) getDisplayTerms();

		SimpleDateFormat dateFormat = new SimpleDateFormat(TienSuConstants.DATE_PATTERN);

	

		if (displayTerms.getTuNgayToaAn() != null) {
			iteratorURL.setParameter(DSHoGiaDinhDisplayTerms.TU_NGAY_TOA_AN,
					dateFormat.format(displayTerms.getTuNgayToaAn()));
		}

		if (displayTerms.getDenNgayToaAn() != null) {
			iteratorURL.setParameter(DSHoGiaDinhDisplayTerms.DEN_NGAY_TOA_AN,
					dateFormat.format(displayTerms.getDenNgayToaAn()));
		}
		iteratorURL.setParameter(DSHoGiaDinhDisplayTerms.TINH_ID,
				String.valueOf(displayTerms.getTinhId()));
		iteratorURL.setParameter(DSHoGiaDinhDisplayTerms.QUAN_HUYEN_ID,
				String.valueOf(displayTerms.getQuanHuyenId()));
		iteratorURL.setParameter(DSHoGiaDinhDisplayTerms.PHUONG_XA_ID,
				String.valueOf(displayTerms.getPhuongXaId()));

	}
}
